var ClubChangeNoticeWindow = Window.extend({
    _ccsFileName: res.ClubChangeNoticeWindow_json,
    _clubId: null,
    initWindow: function (clubId) {
        this._clubId = clubId;
        var clubInfo = ClubDataManager.getClubData(this._clubId);
        var notice = clubInfo['notice'] == '' ? '暂无公告！' : clubInfo['notice'];
        var ggContent = '【' + clubInfo['name'] + '】亲友圈：' + notice;
        if (!notice) {
            ggContent = '亲友圈暂无公告';
        }
        this._nodeList['noticeLookUp.lb_content'].setString(ggContent);
        this._nodeList['noticeLookUp.btn_change'].setVisible(ClubDataManager.isSelfAdministration(this._clubId, gameData.uid));
        this._nodeList['noticeLookUp'].setVisible(true);
        this._nodeList['noticeChange'].setVisible(false);
        this._nodeList['noticeChange.input'].setString('');
        this._nodeList['noticeChange.input'].setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
        this._nodeList['noticeChange.input'].addEventListener(function (textField, type) {
            switch (type) {
                case ccui.TextField.EVENT_ATTACH_WITH_IME:
                    if (cc.sys.os == cc.sys.OS_IOS) {
                        this.setPositionY(320);
                    }
                    break;
                case ccui.TextField.EVENT_DETACH_WITH_IME:
                    this.setPositionY(0);
                    break;
                case ccui.TextField.EVENT_INSERT_TEXT:
                    break;
                case ccui.TextField.EVENT_DELETE_BACKWARD:
                    break;
                default:
                    break;
            }
        }, this);
    },

    _initClickListeners: function () {
        this._clickListeners = {
            'noticeLookUp.btn_change': '_clickChangeNotice',
            'noticeChange.bnt_sure': '_clickSureChange',

        };
    },

    _clickChangeNotice: function () {
        this._nodeList['noticeLookUp'].setVisible(false);
        this._nodeList['noticeChange'].setVisible(true);
    },

    _clickSureChange: function () {
        var str = this._nodeList['noticeChange.input'].getString();
        if (str.length <= 0) {
            showAlert('公告不能为空');
            return;
        }
        if (str.length > 20) {
            showAlert('最多20个汉字或者数字');
            return;
        }
        network.send(2103, {cmd: ClubMsgCode.ModifyClub, club_id: this._clubId, notice: str});
        this.close();
    },
});